package com.tchintech.pay.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tchintech.pay.R;
import com.tchintech.pay.model.entity.ShopUnit;

import java.util.List;

/**
 * Created by Administrator on 2017/8/19 0019.
 */

public class ShoppingunitAdapter extends BaseAdapter {
    private Context context;
    private List<ShopUnit> list;

    public ShoppingunitAdapter(Context context, List<ShopUnit> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public ShopUnit getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View v, ViewGroup parent) {
        ViewHolde vh = null;
        if (v == null) {
            vh = new ViewHolde();
            v = LayoutInflater.from(context).inflate(R.layout.item_shoputil, null);
            vh.tv_item = (TextView) v.findViewById(R.id.tv_item);
            v.setTag(vh);
        } else {
            vh = (ViewHolde) v.getTag();
        }
        ShopUnit shopUnit = list.get(position);
        vh.tv_item.setText(shopUnit.getAlias_name());
        return v;
    }

    class ViewHolde {
        TextView tv_item;
    }
}
